import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IndexComponent } from './index/index.component';
import { AuthGuard } from '../auth/auth-guard.service';

const routes: Routes = [
  {
    path: '',
    component: IndexComponent,
    children: [
      {
        path: 'message',
        canActivate: [AuthGuard],
        loadChildren: () => import('./message/message.module').then(m => m.MessageModule)
      },
      {
        path: 'friend',
        canActivate: [AuthGuard],
        loadChildren: () => import('./friends/friends.module').then(m => m.FriendsModule)
      },
      {
        path: 'explore',
        canActivate: [AuthGuard],
        loadChildren: () => import('./explore/explore.module').then(m => m.ExploreModule)
      },
      {
        path: 'setting',
        canActivate: [AuthGuard],
        loadChildren: () => import('./setting/setting.module').then(m => m.SettingModule)
      },
      {
        path: '',
        redirectTo: 'message',
        pathMatch: 'full',
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class PagesRoutingModule {}
